<?php
/**
 * Abstract class for files treatment
 */ 
abstract class File
{
  protected $path;
  protected $type;
  
  public function __construct($path)
  {
    $this->path = $path;
  }
  
  /**
   * get the file's base name, with (default) or without the extension
   * @param boolean
   * @return string
   */           
  public function getBaseName($ext=true)
  {
    $path_infos = pathinfo($this->path);
    if($ext)
    {
      return($path_infos['basename']);
    }
    else{
      return(basename($this->path,'.'.$path_infos['extension']));
    }
  }
  
  /**
   * get the file's directory name (full path)
   * @return string path
   */        
  public function getDir()
  {
    return(dirname($this->path));
  }
  
  /**
   * get the file's extension
   * @return string extension
   */        
  public function getExt()
  {
    $path_infos = pathinfo($this->path);
    return($path_infos['extension']);
  }
  
  /**
   * get the file mime type
   * 
   * this needs to be implemented in classes that inherits from this one
   * @return string mime type
   */   
  public function getType()
  {
    return $this->type;
  }

}
?>
